package com.lwl.entity;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Lei
 * @create 2022-10-15 0:47
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LayData {

//    layui接收数据时，只有code等于0才算是数据上传成功
    private Integer code = 0;
    private String msg = "";
    private Long count;
    private Object data;

    public LayData(Object data) {
        this.code = 0;
        this.msg = "成功";
        if (data instanceof PageInfo){
            this.count = ((PageInfo) data).getTotal();
            this.data = ((PageInfo<?>) data).getList();
        }else {
            this.data = data;
        }
    }
}
